#coding=utf-8
import unittest
import os
from  util import findutil
from selenium import webdriver
from util import urlutil

class LF_login(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.url = urlutil.UrlList()

        pass

    def setUp(self):
        # 打开Chrome
        self.driver = webdriver.Chrome()
        # 打开指定url
        self.driver.get(self.url.LongFor_Login)
        # 打开最大化窗口
        self.driver.maximize_window()
        # 设置休眠等待
        self.driver.implicitly_wait(10)
        pass

    # def test_us_false_pd_true(self):
    #     """用户名错误密码正确"""
    #     login_name = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[2]/input')
    #     login_password = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[3]/input')
    #     button = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[4]/button')
    #     login_name.send_keys("liu")
    #     login_password.send_keys('qiuye19661013')
    #     button.click()
    # u"""用户名密码都为空"""
    # def test_us_em_pd_em(self):
    #
    #     button = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[4]/button')
    #     button.click()
    #     self.driver.implicitly_wait(3)
    #     login_text = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[5]/span').text
    #     self.assertEqual(login_text, u'用户名或密码不能为空')

    def test_us_true_pd_true(self):
        """用户名密码都正确，登录成功"""
        login_name = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[2]/input')
        login_name.send_keys("liuben")
        login_password = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[3]/input')
        login_password.send_keys('qiuye19661013')
        button = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div/div[4]/button')
        button.click()
        self.driver.implicitly_wait(4)

        # person_num = findutil.FindXPATH(self.driver,'//*[@id="app"]/div[2]/div[2]/div[1]/ul/li[1]/div/div[2]/p')

        # # value = person_num.get_attribute('class')
        # person_num.getElementByClass('class')
        # ss = str(person_num)
        #
        # self.assertEqual(ss,'5')
        #
        # dir = os.getcwd()
        # file = dir +"/ang.txt"
        # w = open('ang.txt','wb')
        # w.write(ss)
        # w.close()

        #切换到人才盘点
        self.driver.current_window_handle
        tab_team_overview = self.driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/ul/li[2]/a')
        tab_team_overview.click()

        pass

    def tearDown(self):
        self.driver.quit()
        pass


